'use strict';

function timeFilter(time, symbol) {
    time = Number(time);
    return function(curr) {
        let start = Number(curr);
        switch (symbol) {
            case 'gt':
                return time <= start;
            case 'lt':
                return time >= start;
            default:
                return false;

        }
    }
}


function domainFilter(domain) {
    return function(meta) {
        return meta.recording.meta['bbb-origin-server-name'] == domain;
    }
}

function nameFilter(name) {
    return function(meta) {
        return meta.recording.meeting.name.indexOf(name) >= 0;
    }
}

function coursesFilter(courses) {
    return function(meta) {
        return meta.recording.meta["bbb-context"].indexOf(courses) >= 0;
    }
}

function Filters(filters) {

    return function() {
        for (let i = 0; i < filters.length; i++) {
            if (!filters[i].apply(this, arguments)) {
                return false;
            }
        }
        return true;
    }
}

module.exports = {
    coursesFilter,
    nameFilter,
    timeFilter,
    domainFilter,
    Filters
}









